function f_check_work_is_run()
{
    declare __t __tools sql fun_name is_has exe_state _wait_time
    fun_name="f_check_work_is_run"
    __tools="${1}"
    __t="${2}"

    exe_state="0"

    which socat > /dev/null 2>&1 || yum -y install socat readline-devel readline >/dev/null 2>&1

    sql="select count(*) from ${t_queue_info} where mysql_port = ${mysql_port} and db_name = '${mysql_db}' and t_name = '${__t}';"
    is_has="$(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${sql}" 2>/dev/null)" || exe_state="${?}"

    if [ "${is_has}x" == "0x" ] && [ "${exe_state}x" == "0x" ]
    then
        sql="insert into ${t_queue_info}(order_id,mysql_port,db_name,t_name,run_state,alter_count,a_time,u_time) value(0,${mysql_port},'${mysql_db}','${__t}',0,0,now(),now())"
        timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${sql}" 2>/dev/null || true
    fi

    _wait_mark=1
    for ((_wait_time=0; _wait_time<=${wait_time_for_work}; _wait_time++))
    do
        sql="update ${t_queue_info} set order_id = ${user_order_id} , run_state = 1 , inip = '${localhost_ip}', alter_count = alter_count + 1 where mysql_port = ${mysql_port} and db_name = '${mysql_db}' and t_name = '${__t}' and run_state = 0;
            select count(*) from ${t_queue_info} where mysql_port = ${mysql_port} and db_name = '${mysql_db}' and t_name = '${__t}' and order_id = ${user_order_id} and run_state = 1;"
        is_has="$(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${sql}" 2>/dev/null)" || exe_state="${?}"
        if [ "${is_has}x" == "1x" ] && [ "${exe_state}x" == "0x" ]
        then
            _wait_mark=0
            break
        elif [ "$((${_wait_time}%10))x" == "0x" ] 
        then
            sql="select concat(inip,':',order_id) from ${t_queue_info} where mysql_port = ${mysql_port} and db_name = '${mysql_db}' and t_name = '${__t}' and run_state = 1;"
            is_has="$(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${sql}" 2>/dev/null)" || exe_state="${?}"
            f_logging "$(eval echo ${log_addr}):WARN" "该表 '${mysql_db}.${__t}' 已经有${__tools}任务在跑 'order_id:${is_has}', 请等待."

            sql="select concat(inip,':',order_id) from ${t_queue_info} where mysql_port = ${mysql_port} and db_name = '${mysql_db}' and t_name = '${__t}' and run_state = 1 and u_time < date_add(now(), INTERVAL - 1 day);"
            is_has="$(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${sql}" 2>/dev/null)" || exe_state="${?}"
            [ -n "${is_has}" ] && f_logging "$(eval echo ${log_addr}):WARN" "该表 '${mysql_db}.${__t}' 已经有${__tools}任务在跑 但是这个工单已经超过一天未更新状态, 请dba处理 'order_id:${is_has}'."
        fi

        [ -f "${script_queue_dir}/stop_file_for_${mysql_port}" ] && break #这是退出的标志文件, 人为生成这个文件, 可以安全退出, 避免暴力终止而没有清理临时文件

        sleep 1
    done

    [ "${_wait_mark}x" == "1x" ] && f_logging "$(eval echo ${log_addr}):ERROR" "该表 '${mysql_db}.${__t}' 已经有${__tools}任务在跑 '${osc_run_mark_file}', 请稍后再试." "2" "1"

    echo "${_PPID}" > ${osc_run_mark_file} && chattr +i ${osc_run_mark_file} || f_logging "$(eval echo ${log_addr}):ERROR" "创建标志文件失败 ] [ ${osc_run_mark_file}" "2" "1"

    f_logging "$(eval echo ${log_addr}):INFO" "该表 '${mysql_db}.${__t}' 改表任务开始 '${osc_run_mark_file}'." "execute:${execute}"

    return 0
}
